package cn.iocoder.yudao.module.biz.dal.mysql.contract.receive;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.contract.receive.ReceiveRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.contract.receive.vo.*;

/**
 * 合同档案-分期收款 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ReceiveRecordMapper extends BaseMapperX<ReceiveRecordDO> {

    default PageResult<ReceiveRecordDO> selectPage(ReceiveRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReceiveRecordDO>()
                .eqIfPresent(ReceiveRecordDO::getContractArchiveId, reqVO.getContractArchiveId())
                .eqIfPresent(ReceiveRecordDO::getInstalmentCount, reqVO.getInstalmentCount())
                .eqIfPresent(ReceiveRecordDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ReceiveRecordDO::getReceiveDate, reqVO.getReceiveDate())
                .eqIfPresent(ReceiveRecordDO::getReceiveMoney, reqVO.getReceiveMoney())
                .eqIfPresent(ReceiveRecordDO::getReceiptCode, reqVO.getReceiptCode())
                .eqIfPresent(ReceiveRecordDO::getAlreadyReceiveMoney, reqVO.getAlreadyReceiveMoney())
                .eqIfPresent(ReceiveRecordDO::getServiceTerm, reqVO.getServiceTerm())
                .eqIfPresent(ReceiveRecordDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ReceiveRecordDO::getBadDebtReason, reqVO.getBadDebtReason())
                .betweenIfPresent(ReceiveRecordDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ReceiveRecordDO::getIsValid, reqVO.getIsValid())
                .orderByDesc(ReceiveRecordDO::getId));
    }

    void deleteByContractArchiveId(Long contractArchiveId);

    void updateStatusByContractId(ReceiveRecordDO record);
}